package com.generic.test03.demo1;

/**
 * @author bin
 * @date 2025 - 03 -26
 **/
public class MainTest {
    public static void main(String[] args) {
        //通过无参构造器实例化设置
//        MyArrayList<String> myArrayList = new MyArrayList<>();
//        String[] ArrStr = new String[10];
//        myArrayList.setElemData(ArrStr);

        //通过有参构造器实例化
        MyArrayList<String> myArrayList = new MyArrayList<>(String.class,10);
        System.out.println(myArrayList.getElemData().length);

        //动态扩容 - 原来长度 * 2
        myArrayList.ReSize();
        System.out.println("扩容后的个数："+myArrayList.getElemData().length);

        //添加元素
        myArrayList.add("hello");
        //获取集合实际大小
        System.out.println("添加后的实际个数"+myArrayList.size());

        //删除元素
        myArrayList.remove(0);
        System.out.println("删除后的实际个数"+myArrayList.size());

        myArrayList.add("hello");
        //获取集合实际大小
        System.out.println("添加后的实际"+myArrayList.size());

        //设置元素
        myArrayList.set(0,"world");
        System.out.println("设置后的实际个数"+ myArrayList.size());

        //获取元素
        System.out.println("获取的元素内容："+ myArrayList.get(0));

        //判断集合是否为空
        System.out.println("判断集合是否为空："+ myArrayList.isEmpty());

        //复制集合
        MyArrayList<String> MyList1 = new MyArrayList<>(String.class,10);
        MyArrayList<String> MyList2 = new MyArrayList<>(String.class,10);
        for (int i = 0; i < MyList1.getElemData().length; i++) {
            MyList1.set(i,i+"");
        }
        System.out.println(MyList1.get(0));
        System.out.println("MyList1的实际元素个数："+MyList1.size());
        System.out.println("MyList2的实际元素个数："+MyList2.size());

        MyList1.arrayCopy(MyList1.getElemData(),2,MyList2.getElemData(),3,5);
        System.out.println("复制后的MyList2的实际元素个数："+MyList2.size());
    }
}
